package cz.proks.easyhelpdesk.gwt.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

import cz.proks.easyhelpdesk.api.model.User;

public class MemberSaveEvent extends GwtEvent<MemberSaveEvent.Handler> {
    public final static Type<MemberSaveEvent.Handler> TYPE = new Type<MemberSaveEvent.Handler>();
    
    public static interface Handler extends EventHandler {
        void onMemberSave(MemberSaveEvent event);
    }
    
    private final User user;

    public MemberSaveEvent(User user) {    
        this.user = user;
    }
    
    public static void fireEvent(HasMemberSaveHandlers source, User user) {
        source.fireEvent(new MemberSaveEvent(user));
    }

    public User getMember() {
        return user;
    }

    @Override
    public com.google.gwt.event.shared.GwtEvent.Type<Handler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(Handler handler) {
        handler.onMemberSave(this);
    }    
}
